const developmentConfig = require('./config/webpack.dev');
const productionConfig = require('./config/webpack.prod');
const { merge } = require('webpack-merge');
const path = require('path')

let config = {
    output: {
        path: path.resolve(__dirname, 'dist'),
        filename: '[name].[hash].js'
    }
}

module.exports = () => {
    switch (process.env.NODE_ENV) {
        case 'development':
            return merge(config, developmentConfig);
        case 'production':
            return merge(config, productionConfig);
        default:
            throw new Error('No matching configuration was found!');
    }
}